package com.scoy.honeymei.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.request.RequestOptions;
import com.scoy.honeymei.R;
import com.scoy.honeymei.install.GlideApp;
import com.scoy.honeymei.install.GlideRoundTransform;
import com.scoy.honeymei.url.MyUrl;


public class GlideImgUtil {

    /**
     * 加载头像
     *
     * @param context
     * @param smallImg
     * @param imageView
     */
    public static void glideHead(Context context, String smallImg, ImageView imageView) {
        if (smallImg != null && smallImg.length() > 0) {
            GlideApp.with(context).load(/*MyUrl.PREFIX_PIC +*/ smallImg).error(R.mipmap.ic_normal_iv).into(imageView);
        } else {
            GlideApp.with(context).load(R.mipmap.ic_normal_iv).into(imageView);
        }
    }

    /**
     * 加载普通图片
     *
     * @param context   1
     * @param smallImg  1
     * @param imageView 1
     */

    public static void glidePic(Context context, String smallImg, ImageView imageView) {
        GlideApp.with(context).load(MyUrl.PREFIX_PIC + smallImg).error(R.color.colorMainGraye).into(imageView);

    }

    public static void glidePicNo(Context context, String smallImg, ImageView imageView) {
        GlideApp.with(context).load(smallImg).error(R.color.colorMainGraye).into(imageView);

    }

    public static void glidePic(Context context, int smallImg, ImageView imageView) {
        GlideApp.with(context).load(smallImg).placeholder(R.color.colorMainGraye).into(imageView);

    }

    public static void glidePic(Context context, String smallImg, ImageView imageView, int radius) {
        GlideApp.with(context).load(MyUrl.PREFIX_PIC + smallImg).placeholder(R.color.colorMainGraye).apply(RequestOptions.bitmapTransform(new GlideRoundTransform(context, radius))).into(imageView);
    }

    public static void glidePicNo(Context context, String smallImg, ImageView imageView, int radius) {
        GlideApp.with(context).load(smallImg).placeholder(R.color.colorMainGraye).apply(RequestOptions.bitmapTransform(new GlideRoundTransform(context, radius))).into(imageView);
    }

    public static void glidePic(Context context, String smallImg, ImageView imageView, int radius, int resId) {
        GlideApp.with(context).load(MyUrl.PREFIX_PIC + smallImg).placeholder(resId).apply(RequestOptions.bitmapTransform(new GlideRoundTransform(context, radius))).into(imageView);
    }

}
